import { useUserStore } from '@/stores/user';
import { createRouter, createWebHashHistory,RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        component: () => import('@/views/home/index.vue'),
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

// 路由守卫
router.beforeEach((to,from,next) => {
    // const userStore = useUserStore();

    // // 用户无 token 则跳转至登录页面
    // if((to.path != '/login' && !userStore.userInfo?.token) && to.path != '/register') {
    //     next('/login');
    // }else {
    //     next();
    // }
    next();
})

export default router;